package bank;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Login extends JPanel implements ActionListener {
    private Atm frame;
    private Icon btnLand = Util.getIcon("/images/buttonLand.jpg");
    private Icon btnOff = Util.getIcon("/images/buttonOff.jpg");
    private JButton imageBtn1 = new JButton(btnLand);
    private JButton imageBtn2 = new JButton(btnOff);

    public Login(Atm frame) {
        this.frame=frame;
        this.setLayout(null);
        this.setOpaque(false);
        JLabel login = new JLabel("登录");
        login.setBounds(50, 50, 100, 50);
        this.add(login);


        imageBtn1.setBounds(250, 430, 140, 50);
        this.add(imageBtn1);
        imageBtn1.addActionListener(this);

        imageBtn2.setBounds(650, 430, 140, 50);
        this.add(imageBtn2);
        imageBtn2.addActionListener(this);

    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == imageBtn1) {
            frame.switchPanel("menu");
        }else if (e.getSource() == imageBtn2){
            System.exit(0);
        }
    }
}
